<template>
  <div class="comment-item">
    <div class="row">
      <!-- 昵称+头像 -->
      <div class="left">
        <img v-lazy="c_item.userInfo.user_photo" />
        <span class="nickName">{{ c_item.userInfo.nickName }}</span>
      </div>
      <div class="right">
        <!-- 时间格式处理 -->
        <div>{{ formatDate(c_item.create_time, "YYYY-MM-DD HH:mm:ss") }}</div>
        <!-- 评分 -->
        <div>
          <rate
            v-model="c_item.star"
            :size="15"
            color="#ffd21e"
            void-icon="star"
            void-color="#eee"
            readonly
          />
        </div>
      </div>
    </div>
    <!-- 详细评论 -->
    <div class="comment-text">{{ c_item.comment_text }}</div>
  </div>
</template>

<script>
import formatDate from "../filters/DateFilter";
import { Rate } from "vant";
export default {
  name: "CommentItem",
  components: { Rate },
  props: {
    c_item: {
      type: Object,
      require: true,
    },
  },
  setup() {
    //   console.log(formatDate);
    //这里为啥一定要抛出呢？
    return { formatDate };
  },
};
</script>

<style lang="scss" scoped>
.comment-item {
  box-sizing: border-box;
  padding: 3px;
  border: 1px solid lightgray;
  .row {
    @include flexbox(row, space-between, center);
    .left {
      @include flexbox(row, flex-start, center);
      img {
        width: 30px;
        height: 30px;
        object-fit: cover;
        border-radius: 30px;
      }
      .nickName {
        margin-left: 5px;
        font-size: 20px;
        line-height: 30px;
      }
    }
    .right {
      @include flexbox(column, space-between, flex-end);
      font-size: 12px;
    }
  }
  .comment-text {
    line-height: 1.6;
  }
}
</style>